<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>mat3.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="local_closure_goog_vec_mat3.js.html">mat3.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2011 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Implements 3x3 matrices and their related functions which are
<a name="line17"></a> * compatible with WebGL. The API is structured to avoid unnecessary memory
<a name="line18"></a> * allocations.  The last parameter will typically be the output vector and
<a name="line19"></a> * an object can be both an input and output parameter to all methods except
<a name="line20"></a> * where noted. Matrix operations follow the mathematical form when multiplying
<a name="line21"></a> * vectors as follows: resultVec = matrix * vec.
<a name="line22"></a> *
<a name="line23"></a> * The matrices are stored in column-major order.
<a name="line24"></a> *
<a name="line25"></a> */
<a name="line26"></a>goog.provide(&#39;goog.vec.Mat3&#39;);
<a name="line27"></a>
<a name="line28"></a>goog.require(&#39;goog.vec&#39;);
<a name="line29"></a>
<a name="line30"></a>
<a name="line31"></a>/** @typedef {goog.vec.Float32} */ goog.vec.Mat3.Float32;
<a name="line32"></a>/** @typedef {goog.vec.Float64} */ goog.vec.Mat3.Float64;
<a name="line33"></a>/** @typedef {goog.vec.Number} */ goog.vec.Mat3.Number;
<a name="line34"></a>/** @typedef {goog.vec.AnyType} */ goog.vec.Mat3.AnyType;
<a name="line35"></a>
<a name="line36"></a>// The following two types are deprecated - use the above types instead.
<a name="line37"></a>/** @typedef {Float32Array} */ goog.vec.Mat3.Type;
<a name="line38"></a>/** @typedef {goog.vec.ArrayType} */ goog.vec.Mat3.Mat3Like;
<a name="line39"></a>
<a name="line40"></a>
<a name="line41"></a>/**
<a name="line42"></a> * Creates the array representation of a 3x3 matrix of Float32.
<a name="line43"></a> * The use of the array directly instead of a class reduces overhead.
<a name="line44"></a> * The returned matrix is cleared to all zeros.
<a name="line45"></a> *
<a name="line46"></a> * @return {!goog.vec.Mat3.Float32} The new matrix.
<a name="line47"></a> */
<a name="line48"></a>goog.vec.Mat3.createFloat32 = function() {
<a name="line49"></a>  return new Float32Array(9);
<a name="line50"></a>};
<a name="line51"></a>
<a name="line52"></a>
<a name="line53"></a>/**
<a name="line54"></a> * Creates the array representation of a 3x3 matrix of Float64.
<a name="line55"></a> * The returned matrix is cleared to all zeros.
<a name="line56"></a> *
<a name="line57"></a> * @return {!goog.vec.Mat3.Float64} The new matrix.
<a name="line58"></a> */
<a name="line59"></a>goog.vec.Mat3.createFloat64 = function() {
<a name="line60"></a>  return new Float64Array(9);
<a name="line61"></a>};
<a name="line62"></a>
<a name="line63"></a>
<a name="line64"></a>/**
<a name="line65"></a> * Creates the array representation of a 3x3 matrix of Number.
<a name="line66"></a> * The returned matrix is cleared to all zeros.
<a name="line67"></a> *
<a name="line68"></a> * @return {!goog.vec.Mat3.Number} The new matrix.
<a name="line69"></a> */
<a name="line70"></a>goog.vec.Mat3.createNumber = function() {
<a name="line71"></a>  var a = new Array(9);
<a name="line72"></a>  goog.vec.Mat3.setFromValues(a,
<a name="line73"></a>                              0, 0, 0,
<a name="line74"></a>                              0, 0, 0,
<a name="line75"></a>                              0, 0, 0);
<a name="line76"></a>  return a;
<a name="line77"></a>};
<a name="line78"></a>
<a name="line79"></a>
<a name="line80"></a>/**
<a name="line81"></a> * Creates the array representation of a 3x3 matrix of Float32.
<a name="line82"></a> * The returned matrix is cleared to all zeros.
<a name="line83"></a> *
<a name="line84"></a> * @deprecated Use createFloat32.
<a name="line85"></a> * @return {!goog.vec.Mat3.Type} The new matrix.
<a name="line86"></a> */
<a name="line87"></a>goog.vec.Mat3.create = function() {
<a name="line88"></a>  return goog.vec.Mat3.createFloat32();
<a name="line89"></a>};
<a name="line90"></a>
<a name="line91"></a>
<a name="line92"></a>/**
<a name="line93"></a> * Creates a 3x3 identity matrix of Float32.
<a name="line94"></a> *
<a name="line95"></a> * @return {!goog.vec.Mat3.Float32} The new 9 element array.
<a name="line96"></a> */
<a name="line97"></a>goog.vec.Mat3.createFloat32Identity = function() {
<a name="line98"></a>  var mat = goog.vec.Mat3.createFloat32();
<a name="line99"></a>  mat[0] = mat[4] = mat[8] = 1;
<a name="line100"></a>  return mat;
<a name="line101"></a>};
<a name="line102"></a>
<a name="line103"></a>
<a name="line104"></a>/**
<a name="line105"></a> * Creates a 3x3 identity matrix of Float64.
<a name="line106"></a> *
<a name="line107"></a> * @return {!goog.vec.Mat3.Float64} The new 9 element array.
<a name="line108"></a> */
<a name="line109"></a>goog.vec.Mat3.createFloat64Identity = function() {
<a name="line110"></a>  var mat = goog.vec.Mat3.createFloat64();
<a name="line111"></a>  mat[0] = mat[4] = mat[8] = 1;
<a name="line112"></a>  return mat;
<a name="line113"></a>};
<a name="line114"></a>
<a name="line115"></a>
<a name="line116"></a>/**
<a name="line117"></a> * Creates a 3x3 identity matrix of Number.
<a name="line118"></a> * The returned matrix is cleared to all zeros.
<a name="line119"></a> *
<a name="line120"></a> * @return {!goog.vec.Mat3.Number} The new 9 element array.
<a name="line121"></a> */
<a name="line122"></a>goog.vec.Mat3.createNumberIdentity = function() {
<a name="line123"></a>  var a = new Array(9);
<a name="line124"></a>  goog.vec.Mat3.setFromValues(a,
<a name="line125"></a>                              1, 0, 0,
<a name="line126"></a>                              0, 1, 0,
<a name="line127"></a>                              0, 0, 1);
<a name="line128"></a>  return a;
<a name="line129"></a>};
<a name="line130"></a>
<a name="line131"></a>
<a name="line132"></a>/**
<a name="line133"></a> * Creates the array representation of a 3x3 matrix of Float32.
<a name="line134"></a> * The returned matrix is cleared to all zeros.
<a name="line135"></a> *
<a name="line136"></a> * @deprecated Use createFloat32Identity.
<a name="line137"></a> * @return {!goog.vec.Mat3.Type} The new 9 element array.
<a name="line138"></a> */
<a name="line139"></a>goog.vec.Mat3.createIdentity = function() {
<a name="line140"></a>  return goog.vec.Mat3.createFloat32Identity();
<a name="line141"></a>};
<a name="line142"></a>
<a name="line143"></a>
<a name="line144"></a>/**
<a name="line145"></a> * Creates a 3x3 matrix of Float32 initialized from the given array.
<a name="line146"></a> *
<a name="line147"></a> * @param {goog.vec.Mat3.AnyType} matrix The array containing the
<a name="line148"></a> *     matrix values in column major order.
<a name="line149"></a> * @return {!goog.vec.Mat3.Float32} The new, nine element array.
<a name="line150"></a> */
<a name="line151"></a>goog.vec.Mat3.createFloat32FromArray = function(matrix) {
<a name="line152"></a>  var newMatrix = goog.vec.Mat3.createFloat32();
<a name="line153"></a>  goog.vec.Mat3.setFromArray(newMatrix, matrix);
<a name="line154"></a>  return newMatrix;
<a name="line155"></a>};
<a name="line156"></a>
<a name="line157"></a>
<a name="line158"></a>/**
<a name="line159"></a> * Creates a 3x3 matrix of Float32 initialized from the given values.
<a name="line160"></a> *
<a name="line161"></a> * @param {number} v00 The values at (0, 0).
<a name="line162"></a> * @param {number} v10 The values at (1, 0).
<a name="line163"></a> * @param {number} v20 The values at (2, 0).
<a name="line164"></a> * @param {number} v01 The values at (0, 1).
<a name="line165"></a> * @param {number} v11 The values at (1, 1).
<a name="line166"></a> * @param {number} v21 The values at (2, 1).
<a name="line167"></a> * @param {number} v02 The values at (0, 2).
<a name="line168"></a> * @param {number} v12 The values at (1, 2).
<a name="line169"></a> * @param {number} v22 The values at (2, 2).
<a name="line170"></a> * @return {!goog.vec.Mat3.Float32} The new, nine element array.
<a name="line171"></a> */
<a name="line172"></a>goog.vec.Mat3.createFloat32FromValues = function(
<a name="line173"></a>    v00, v10, v20, v01, v11, v21, v02, v12, v22) {
<a name="line174"></a>  var newMatrix = goog.vec.Mat3.createFloat32();
<a name="line175"></a>  goog.vec.Mat3.setFromValues(
<a name="line176"></a>      newMatrix, v00, v10, v20, v01, v11, v21, v02, v12, v22);
<a name="line177"></a>  return newMatrix;
<a name="line178"></a>};
<a name="line179"></a>
<a name="line180"></a>
<a name="line181"></a>/**
<a name="line182"></a> * Creates a clone of a 3x3 matrix of Float32.
<a name="line183"></a> *
<a name="line184"></a> * @param {goog.vec.Mat3.Float32} matrix The source 3x3 matrix.
<a name="line185"></a> * @return {!goog.vec.Mat3.Float32} The new 3x3 element matrix.
<a name="line186"></a> */
<a name="line187"></a>goog.vec.Mat3.cloneFloat32 = goog.vec.Mat3.createFloat32FromArray;
<a name="line188"></a>
<a name="line189"></a>
<a name="line190"></a>/**
<a name="line191"></a> * Creates a 3x3 matrix of Float64 initialized from the given array.
<a name="line192"></a> *
<a name="line193"></a> * @param {goog.vec.Mat3.AnyType} matrix The array containing the
<a name="line194"></a> *     matrix values in column major order.
<a name="line195"></a> * @return {!goog.vec.Mat3.Float64} The new, nine element array.
<a name="line196"></a> */
<a name="line197"></a>goog.vec.Mat3.createFloat64FromArray = function(matrix) {
<a name="line198"></a>  var newMatrix = goog.vec.Mat3.createFloat64();
<a name="line199"></a>  goog.vec.Mat3.setFromArray(newMatrix, matrix);
<a name="line200"></a>  return newMatrix;
<a name="line201"></a>};
<a name="line202"></a>
<a name="line203"></a>
<a name="line204"></a>/**
<a name="line205"></a> * Creates a 3x3 matrix of Float64 initialized from the given values.
<a name="line206"></a> *
<a name="line207"></a> * @param {number} v00 The values at (0, 0).
<a name="line208"></a> * @param {number} v10 The values at (1, 0).
<a name="line209"></a> * @param {number} v20 The values at (2, 0).
<a name="line210"></a> * @param {number} v01 The values at (0, 1).
<a name="line211"></a> * @param {number} v11 The values at (1, 1).
<a name="line212"></a> * @param {number} v21 The values at (2, 1).
<a name="line213"></a> * @param {number} v02 The values at (0, 2).
<a name="line214"></a> * @param {number} v12 The values at (1, 2).
<a name="line215"></a> * @param {number} v22 The values at (2, 2).
<a name="line216"></a> * @return {!goog.vec.Mat3.Float64} The new, nine element array.
<a name="line217"></a> */
<a name="line218"></a>goog.vec.Mat3.createFloat64FromValues = function(
<a name="line219"></a>    v00, v10, v20, v01, v11, v21, v02, v12, v22) {
<a name="line220"></a>  var newMatrix = goog.vec.Mat3.createFloat64();
<a name="line221"></a>  goog.vec.Mat3.setFromValues(
<a name="line222"></a>      newMatrix, v00, v10, v20, v01, v11, v21, v02, v12, v22);
<a name="line223"></a>  return newMatrix;
<a name="line224"></a>};
<a name="line225"></a>
<a name="line226"></a>
<a name="line227"></a>/**
<a name="line228"></a> * Creates a clone of a 3x3 matrix of Float64.
<a name="line229"></a> *
<a name="line230"></a> * @param {goog.vec.Mat3.Float64} matrix The source 3x3 matrix.
<a name="line231"></a> * @return {!goog.vec.Mat3.Float64} The new 3x3 element matrix.
<a name="line232"></a> */
<a name="line233"></a>goog.vec.Mat3.cloneFloat64 = goog.vec.Mat3.createFloat64FromArray;
<a name="line234"></a>
<a name="line235"></a>
<a name="line236"></a>/**
<a name="line237"></a> * Creates a 3x3 matrix of Float32 initialized from the given array.
<a name="line238"></a> *
<a name="line239"></a> * @deprecated Use createFloat32FromArray.
<a name="line240"></a> * @param {goog.vec.Mat3.Mat3Like} matrix The array containing the
<a name="line241"></a> *     matrix values in column major order.
<a name="line242"></a> * @return {!goog.vec.Mat3.Type} The new, nine element array.
<a name="line243"></a> */
<a name="line244"></a>goog.vec.Mat3.createFromArray = function(matrix) {
<a name="line245"></a>  var newMatrix = goog.vec.Mat3.createFloat32();
<a name="line246"></a>  goog.vec.Mat3.setFromArray(newMatrix, matrix);
<a name="line247"></a>  return newMatrix;
<a name="line248"></a>};
<a name="line249"></a>
<a name="line250"></a>
<a name="line251"></a>/**
<a name="line252"></a> * Creates a 3x3 matrix of Float32 initialized from the given values.
<a name="line253"></a> *
<a name="line254"></a> * @deprecated Use createFloat32FromValues.
<a name="line255"></a> * @param {number} v00 The values at (0, 0).
<a name="line256"></a> * @param {number} v10 The values at (1, 0).
<a name="line257"></a> * @param {number} v20 The values at (2, 0).
<a name="line258"></a> * @param {number} v01 The values at (0, 1).
<a name="line259"></a> * @param {number} v11 The values at (1, 1).
<a name="line260"></a> * @param {number} v21 The values at (2, 1).
<a name="line261"></a> * @param {number} v02 The values at (0, 2).
<a name="line262"></a> * @param {number} v12 The values at (1, 2).
<a name="line263"></a> * @param {number} v22 The values at (2, 2).
<a name="line264"></a> * @return {!goog.vec.Mat3.Type} The new, nine element array.
<a name="line265"></a> */
<a name="line266"></a>goog.vec.Mat3.createFromValues = function(
<a name="line267"></a>    v00, v10, v20, v01, v11, v21, v02, v12, v22) {
<a name="line268"></a>  var newMatrix = goog.vec.Mat3.create();
<a name="line269"></a>  goog.vec.Mat3.setFromValues(
<a name="line270"></a>      newMatrix, v00, v10, v20, v01, v11, v21, v02, v12, v22);
<a name="line271"></a>  return newMatrix;
<a name="line272"></a>};
<a name="line273"></a>
<a name="line274"></a>
<a name="line275"></a>/**
<a name="line276"></a> * Creates a clone of a 3x3 matrix of Float32.
<a name="line277"></a> *
<a name="line278"></a> * @deprecated Use cloneFloat32.
<a name="line279"></a> * @param {goog.vec.Mat3.Mat3Like} matrix The source 3x3 matrix.
<a name="line280"></a> * @return {!goog.vec.Mat3.Type} The new 3x3 element matrix.
<a name="line281"></a> */
<a name="line282"></a>goog.vec.Mat3.clone = goog.vec.Mat3.createFromArray;
<a name="line283"></a>
<a name="line284"></a>
<a name="line285"></a>/**
<a name="line286"></a> * Retrieves the element at the requested row and column.
<a name="line287"></a> *
<a name="line288"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix containing the value to
<a name="line289"></a> *     retrieve.
<a name="line290"></a> * @param {number} row The row index.
<a name="line291"></a> * @param {number} column The column index.
<a name="line292"></a> * @return {number} The element value at the requested row, column indices.
<a name="line293"></a> */
<a name="line294"></a>goog.vec.Mat3.getElement = function(mat, row, column) {
<a name="line295"></a>  return mat[row + column * 3];
<a name="line296"></a>};
<a name="line297"></a>
<a name="line298"></a>
<a name="line299"></a>/**
<a name="line300"></a> * Sets the element at the requested row and column.
<a name="line301"></a> *
<a name="line302"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix containing the value to
<a name="line303"></a> *     retrieve.
<a name="line304"></a> * @param {number} row The row index.
<a name="line305"></a> * @param {number} column The column index.
<a name="line306"></a> * @param {number} value The value to set at the requested row, column.
<a name="line307"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line308"></a> *     chained together.
<a name="line309"></a> */
<a name="line310"></a>goog.vec.Mat3.setElement = function(mat, row, column, value) {
<a name="line311"></a>  mat[row + column * 3] = value;
<a name="line312"></a>  return mat;
<a name="line313"></a>};
<a name="line314"></a>
<a name="line315"></a>
<a name="line316"></a>/**
<a name="line317"></a> * Initializes the matrix from the set of values. Note the values supplied are
<a name="line318"></a> * in column major order.
<a name="line319"></a> *
<a name="line320"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the
<a name="line321"></a> *     values.
<a name="line322"></a> * @param {number} v00 The values at (0, 0).
<a name="line323"></a> * @param {number} v10 The values at (1, 0).
<a name="line324"></a> * @param {number} v20 The values at (2, 0).
<a name="line325"></a> * @param {number} v01 The values at (0, 1).
<a name="line326"></a> * @param {number} v11 The values at (1, 1).
<a name="line327"></a> * @param {number} v21 The values at (2, 1).
<a name="line328"></a> * @param {number} v02 The values at (0, 2).
<a name="line329"></a> * @param {number} v12 The values at (1, 2).
<a name="line330"></a> * @param {number} v22 The values at (2, 2).
<a name="line331"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line332"></a> *     chained together.
<a name="line333"></a> */
<a name="line334"></a>goog.vec.Mat3.setFromValues = function(
<a name="line335"></a>    mat, v00, v10, v20, v01, v11, v21, v02, v12, v22) {
<a name="line336"></a>  mat[0] = v00;
<a name="line337"></a>  mat[1] = v10;
<a name="line338"></a>  mat[2] = v20;
<a name="line339"></a>  mat[3] = v01;
<a name="line340"></a>  mat[4] = v11;
<a name="line341"></a>  mat[5] = v21;
<a name="line342"></a>  mat[6] = v02;
<a name="line343"></a>  mat[7] = v12;
<a name="line344"></a>  mat[8] = v22;
<a name="line345"></a>  return mat;
<a name="line346"></a>};
<a name="line347"></a>
<a name="line348"></a>
<a name="line349"></a>/**
<a name="line350"></a> * Sets the matrix from the array of values stored in column major order.
<a name="line351"></a> *
<a name="line352"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the values.
<a name="line353"></a> * @param {goog.vec.Mat3.AnyType} values The column major ordered
<a name="line354"></a> *     array of values to store in the matrix.
<a name="line355"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line356"></a> *     chained together.
<a name="line357"></a> */
<a name="line358"></a>goog.vec.Mat3.setFromArray = function(mat, values) {
<a name="line359"></a>  mat[0] = values[0];
<a name="line360"></a>  mat[1] = values[1];
<a name="line361"></a>  mat[2] = values[2];
<a name="line362"></a>  mat[3] = values[3];
<a name="line363"></a>  mat[4] = values[4];
<a name="line364"></a>  mat[5] = values[5];
<a name="line365"></a>  mat[6] = values[6];
<a name="line366"></a>  mat[7] = values[7];
<a name="line367"></a>  mat[8] = values[8];
<a name="line368"></a>  return mat;
<a name="line369"></a>};
<a name="line370"></a>
<a name="line371"></a>
<a name="line372"></a>/**
<a name="line373"></a> * Sets the matrix from the array of values stored in row major order.
<a name="line374"></a> *
<a name="line375"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the values.
<a name="line376"></a> * @param {goog.vec.Mat3.AnyType} values The row major ordered array
<a name="line377"></a> *     of values to store in the matrix.
<a name="line378"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line379"></a> *     chained together.
<a name="line380"></a> */
<a name="line381"></a>goog.vec.Mat3.setFromRowMajorArray = function(mat, values) {
<a name="line382"></a>  mat[0] = values[0];
<a name="line383"></a>  mat[1] = values[3];
<a name="line384"></a>  mat[2] = values[6];
<a name="line385"></a>  mat[3] = values[1];
<a name="line386"></a>  mat[4] = values[4];
<a name="line387"></a>  mat[5] = values[7];
<a name="line388"></a>  mat[6] = values[2];
<a name="line389"></a>  mat[7] = values[5];
<a name="line390"></a>  mat[8] = values[8];
<a name="line391"></a>  return mat;
<a name="line392"></a>};
<a name="line393"></a>
<a name="line394"></a>
<a name="line395"></a>/**
<a name="line396"></a> * Sets the diagonal values of the matrix from the given values.
<a name="line397"></a> *
<a name="line398"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the values.
<a name="line399"></a> * @param {number} v00 The values for (0, 0).
<a name="line400"></a> * @param {number} v11 The values for (1, 1).
<a name="line401"></a> * @param {number} v22 The values for (2, 2).
<a name="line402"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line403"></a> *     chained together.
<a name="line404"></a> */
<a name="line405"></a>goog.vec.Mat3.setDiagonalValues = function(mat, v00, v11, v22) {
<a name="line406"></a>  mat[0] = v00;
<a name="line407"></a>  mat[4] = v11;
<a name="line408"></a>  mat[8] = v22;
<a name="line409"></a>  return mat;
<a name="line410"></a>};
<a name="line411"></a>
<a name="line412"></a>
<a name="line413"></a>/**
<a name="line414"></a> * Sets the diagonal values of the matrix from the given vector.
<a name="line415"></a> *
<a name="line416"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the values.
<a name="line417"></a> * @param {goog.vec.Vec3.AnyType} vec The vector containing the values.
<a name="line418"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line419"></a> *     chained together.
<a name="line420"></a> */
<a name="line421"></a>goog.vec.Mat3.setDiagonal = function(mat, vec) {
<a name="line422"></a>  mat[0] = vec[0];
<a name="line423"></a>  mat[4] = vec[1];
<a name="line424"></a>  mat[8] = vec[2];
<a name="line425"></a>  return mat;
<a name="line426"></a>};
<a name="line427"></a>
<a name="line428"></a>
<a name="line429"></a>/**
<a name="line430"></a> * Sets the specified column with the supplied values.
<a name="line431"></a> *
<a name="line432"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to recieve the values.
<a name="line433"></a> * @param {number} column The column index to set the values on.
<a name="line434"></a> * @param {number} v0 The value for row 0.
<a name="line435"></a> * @param {number} v1 The value for row 1.
<a name="line436"></a> * @param {number} v2 The value for row 2.
<a name="line437"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line438"></a> *     chained together.
<a name="line439"></a> */
<a name="line440"></a>goog.vec.Mat3.setColumnValues = function(mat, column, v0, v1, v2) {
<a name="line441"></a>  var i = column * 3;
<a name="line442"></a>  mat[i] = v0;
<a name="line443"></a>  mat[i + 1] = v1;
<a name="line444"></a>  mat[i + 2] = v2;
<a name="line445"></a>  return mat;
<a name="line446"></a>};
<a name="line447"></a>
<a name="line448"></a>
<a name="line449"></a>/**
<a name="line450"></a> * Sets the specified column with the value from the supplied array.
<a name="line451"></a> *
<a name="line452"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the values.
<a name="line453"></a> * @param {number} column The column index to set the values on.
<a name="line454"></a> * @param {goog.vec.Vec3.AnyType} vec The vector elements for the column.
<a name="line455"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line456"></a> *     chained together.
<a name="line457"></a> */
<a name="line458"></a>goog.vec.Mat3.setColumn = function(mat, column, vec) {
<a name="line459"></a>  var i = column * 3;
<a name="line460"></a>  mat[i] = vec[0];
<a name="line461"></a>  mat[i + 1] = vec[1];
<a name="line462"></a>  mat[i + 2] = vec[2];
<a name="line463"></a>  return mat;
<a name="line464"></a>};
<a name="line465"></a>
<a name="line466"></a>
<a name="line467"></a>/**
<a name="line468"></a> * Retrieves the specified column from the matrix into the given vector
<a name="line469"></a> * array.
<a name="line470"></a> *
<a name="line471"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix supplying the values.
<a name="line472"></a> * @param {number} column The column to get the values from.
<a name="line473"></a> * @param {goog.vec.Vec3.AnyType} vec The vector elements to receive the
<a name="line474"></a> *     column.
<a name="line475"></a> * @return {goog.vec.Vec3.AnyType} return vec so that operations can be
<a name="line476"></a> *     chained together.
<a name="line477"></a> */
<a name="line478"></a>goog.vec.Mat3.getColumn = function(mat, column, vec) {
<a name="line479"></a>  var i = column * 3;
<a name="line480"></a>  vec[0] = mat[i];
<a name="line481"></a>  vec[1] = mat[i + 1];
<a name="line482"></a>  vec[2] = mat[i + 2];
<a name="line483"></a>  return vec;
<a name="line484"></a>};
<a name="line485"></a>
<a name="line486"></a>
<a name="line487"></a>/**
<a name="line488"></a> * Sets the columns of the matrix from the set of vector elements.
<a name="line489"></a> *
<a name="line490"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the values.
<a name="line491"></a> * @param {goog.vec.Vec3.AnyType} vec0 The values for column 0.
<a name="line492"></a> * @param {goog.vec.Vec3.AnyType} vec1 The values for column 1.
<a name="line493"></a> * @param {goog.vec.Vec3.AnyType} vec2 The values for column 2.
<a name="line494"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line495"></a> *     chained together.
<a name="line496"></a> */
<a name="line497"></a>goog.vec.Mat3.setColumns = function(mat, vec0, vec1, vec2) {
<a name="line498"></a>  goog.vec.Mat3.setColumn(mat, 0, vec0);
<a name="line499"></a>  goog.vec.Mat3.setColumn(mat, 1, vec1);
<a name="line500"></a>  goog.vec.Mat3.setColumn(mat, 2, vec2);
<a name="line501"></a>  return mat;
<a name="line502"></a>};
<a name="line503"></a>
<a name="line504"></a>
<a name="line505"></a>/**
<a name="line506"></a> * Retrieves the column values from the given matrix into the given vector
<a name="line507"></a> * elements.
<a name="line508"></a> *
<a name="line509"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix supplying the columns.
<a name="line510"></a> * @param {goog.vec.Vec3.AnyType} vec0 The vector to receive column 0.
<a name="line511"></a> * @param {goog.vec.Vec3.AnyType} vec1 The vector to receive column 1.
<a name="line512"></a> * @param {goog.vec.Vec3.AnyType} vec2 The vector to receive column 2.
<a name="line513"></a> */
<a name="line514"></a>goog.vec.Mat3.getColumns = function(mat, vec0, vec1, vec2) {
<a name="line515"></a>  goog.vec.Mat3.getColumn(mat, 0, vec0);
<a name="line516"></a>  goog.vec.Mat3.getColumn(mat, 1, vec1);
<a name="line517"></a>  goog.vec.Mat3.getColumn(mat, 2, vec2);
<a name="line518"></a>};
<a name="line519"></a>
<a name="line520"></a>
<a name="line521"></a>/**
<a name="line522"></a> * Sets the row values from the supplied values.
<a name="line523"></a> *
<a name="line524"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the values.
<a name="line525"></a> * @param {number} row The index of the row to receive the values.
<a name="line526"></a> * @param {number} v0 The value for column 0.
<a name="line527"></a> * @param {number} v1 The value for column 1.
<a name="line528"></a> * @param {number} v2 The value for column 2.
<a name="line529"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line530"></a> *     chained together.
<a name="line531"></a> */
<a name="line532"></a>goog.vec.Mat3.setRowValues = function(mat, row, v0, v1, v2) {
<a name="line533"></a>  mat[row] = v0;
<a name="line534"></a>  mat[row + 3] = v1;
<a name="line535"></a>  mat[row + 6] = v2;
<a name="line536"></a>  return mat;
<a name="line537"></a>};
<a name="line538"></a>
<a name="line539"></a>
<a name="line540"></a>/**
<a name="line541"></a> * Sets the row values from the supplied vector.
<a name="line542"></a> *
<a name="line543"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the row values.
<a name="line544"></a> * @param {number} row The index of the row.
<a name="line545"></a> * @param {goog.vec.Vec3.AnyType} vec The vector containing the values.
<a name="line546"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line547"></a> *     chained together.
<a name="line548"></a> */
<a name="line549"></a>goog.vec.Mat3.setRow = function(mat, row, vec) {
<a name="line550"></a>  mat[row] = vec[0];
<a name="line551"></a>  mat[row + 3] = vec[1];
<a name="line552"></a>  mat[row + 6] = vec[2];
<a name="line553"></a>  return mat;
<a name="line554"></a>};
<a name="line555"></a>
<a name="line556"></a>
<a name="line557"></a>/**
<a name="line558"></a> * Retrieves the row values into the given vector.
<a name="line559"></a> *
<a name="line560"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix supplying the values.
<a name="line561"></a> * @param {number} row The index of the row supplying the values.
<a name="line562"></a> * @param {goog.vec.Vec3.AnyType} vec The vector to receive the row.
<a name="line563"></a> * @return {goog.vec.Vec3.AnyType} return vec so that operations can be
<a name="line564"></a> *     chained together.
<a name="line565"></a> */
<a name="line566"></a>goog.vec.Mat3.getRow = function(mat, row, vec) {
<a name="line567"></a>  vec[0] = mat[row];
<a name="line568"></a>  vec[1] = mat[row + 3];
<a name="line569"></a>  vec[2] = mat[row + 6];
<a name="line570"></a>  return vec;
<a name="line571"></a>};
<a name="line572"></a>
<a name="line573"></a>
<a name="line574"></a>/**
<a name="line575"></a> * Sets the rows of the matrix from the supplied vectors.
<a name="line576"></a> *
<a name="line577"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to receive the values.
<a name="line578"></a> * @param {goog.vec.Vec3.AnyType} vec0 The values for row 0.
<a name="line579"></a> * @param {goog.vec.Vec3.AnyType} vec1 The values for row 1.
<a name="line580"></a> * @param {goog.vec.Vec3.AnyType} vec2 The values for row 2.
<a name="line581"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line582"></a> *     chained together.
<a name="line583"></a> */
<a name="line584"></a>goog.vec.Mat3.setRows = function(mat, vec0, vec1, vec2) {
<a name="line585"></a>  goog.vec.Mat3.setRow(mat, 0, vec0);
<a name="line586"></a>  goog.vec.Mat3.setRow(mat, 1, vec1);
<a name="line587"></a>  goog.vec.Mat3.setRow(mat, 2, vec2);
<a name="line588"></a>  return mat;
<a name="line589"></a>};
<a name="line590"></a>
<a name="line591"></a>
<a name="line592"></a>/**
<a name="line593"></a> * Retrieves the rows of the matrix into the supplied vectors.
<a name="line594"></a> *
<a name="line595"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to supplying the values.
<a name="line596"></a> * @param {goog.vec.Vec3.AnyType} vec0 The vector to receive row 0.
<a name="line597"></a> * @param {goog.vec.Vec3.AnyType} vec1 The vector to receive row 1.
<a name="line598"></a> * @param {goog.vec.Vec3.AnyType} vec2 The vector to receive row 2.
<a name="line599"></a> */
<a name="line600"></a>goog.vec.Mat3.getRows = function(mat, vec0, vec1, vec2) {
<a name="line601"></a>  goog.vec.Mat3.getRow(mat, 0, vec0);
<a name="line602"></a>  goog.vec.Mat3.getRow(mat, 1, vec1);
<a name="line603"></a>  goog.vec.Mat3.getRow(mat, 2, vec2);
<a name="line604"></a>};
<a name="line605"></a>
<a name="line606"></a>
<a name="line607"></a>/**
<a name="line608"></a> * Makes the given 3x3 matrix the zero matrix.
<a name="line609"></a> *
<a name="line610"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line611"></a> * @return {goog.vec.Mat3.AnyType} return mat so operations can be chained.
<a name="line612"></a> */
<a name="line613"></a>goog.vec.Mat3.makeZero = function(mat) {
<a name="line614"></a>  mat[0] = 0;
<a name="line615"></a>  mat[1] = 0;
<a name="line616"></a>  mat[2] = 0;
<a name="line617"></a>  mat[3] = 0;
<a name="line618"></a>  mat[4] = 0;
<a name="line619"></a>  mat[5] = 0;
<a name="line620"></a>  mat[6] = 0;
<a name="line621"></a>  mat[7] = 0;
<a name="line622"></a>  mat[8] = 0;
<a name="line623"></a>  return mat;
<a name="line624"></a>};
<a name="line625"></a>
<a name="line626"></a>
<a name="line627"></a>/**
<a name="line628"></a> * Makes the given 3x3 matrix the identity matrix.
<a name="line629"></a> *
<a name="line630"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line631"></a> * @return {goog.vec.Mat3.AnyType} return mat so operations can be chained.
<a name="line632"></a> */
<a name="line633"></a>goog.vec.Mat3.makeIdentity = function(mat) {
<a name="line634"></a>  mat[0] = 1;
<a name="line635"></a>  mat[1] = 0;
<a name="line636"></a>  mat[2] = 0;
<a name="line637"></a>  mat[3] = 0;
<a name="line638"></a>  mat[4] = 1;
<a name="line639"></a>  mat[5] = 0;
<a name="line640"></a>  mat[6] = 0;
<a name="line641"></a>  mat[7] = 0;
<a name="line642"></a>  mat[8] = 1;
<a name="line643"></a>  return mat;
<a name="line644"></a>};
<a name="line645"></a>
<a name="line646"></a>
<a name="line647"></a>/**
<a name="line648"></a> * Performs a per-component addition of the matrices mat0 and mat1, storing
<a name="line649"></a> * the result into resultMat.
<a name="line650"></a> *
<a name="line651"></a> * @param {goog.vec.Mat3.AnyType} mat0 The first addend.
<a name="line652"></a> * @param {goog.vec.Mat3.AnyType} mat1 The second addend.
<a name="line653"></a> * @param {goog.vec.Mat3.AnyType} resultMat The matrix to
<a name="line654"></a> *     receive the results (may be either mat0 or mat1).
<a name="line655"></a> * @return {goog.vec.Mat3.AnyType} return resultMat so that operations can be
<a name="line656"></a> *     chained together.
<a name="line657"></a> */
<a name="line658"></a>goog.vec.Mat3.addMat = function(mat0, mat1, resultMat) {
<a name="line659"></a>  resultMat[0] = mat0[0] + mat1[0];
<a name="line660"></a>  resultMat[1] = mat0[1] + mat1[1];
<a name="line661"></a>  resultMat[2] = mat0[2] + mat1[2];
<a name="line662"></a>  resultMat[3] = mat0[3] + mat1[3];
<a name="line663"></a>  resultMat[4] = mat0[4] + mat1[4];
<a name="line664"></a>  resultMat[5] = mat0[5] + mat1[5];
<a name="line665"></a>  resultMat[6] = mat0[6] + mat1[6];
<a name="line666"></a>  resultMat[7] = mat0[7] + mat1[7];
<a name="line667"></a>  resultMat[8] = mat0[8] + mat1[8];
<a name="line668"></a>  return resultMat;
<a name="line669"></a>};
<a name="line670"></a>
<a name="line671"></a>
<a name="line672"></a>/**
<a name="line673"></a> * Performs a per-component subtraction of the matrices mat0 and mat1,
<a name="line674"></a> * storing the result into resultMat.
<a name="line675"></a> *
<a name="line676"></a> * @param {goog.vec.Mat3.AnyType} mat0 The minuend.
<a name="line677"></a> * @param {goog.vec.Mat3.AnyType} mat1 The subtrahend.
<a name="line678"></a> * @param {goog.vec.Mat3.AnyType} resultMat The matrix to receive
<a name="line679"></a> *     the results (may be either mat0 or mat1).
<a name="line680"></a> * @return {goog.vec.Mat3.AnyType} return resultMat so that operations can be
<a name="line681"></a> *     chained together.
<a name="line682"></a> */
<a name="line683"></a>goog.vec.Mat3.subMat = function(mat0, mat1, resultMat) {
<a name="line684"></a>  resultMat[0] = mat0[0] - mat1[0];
<a name="line685"></a>  resultMat[1] = mat0[1] - mat1[1];
<a name="line686"></a>  resultMat[2] = mat0[2] - mat1[2];
<a name="line687"></a>  resultMat[3] = mat0[3] - mat1[3];
<a name="line688"></a>  resultMat[4] = mat0[4] - mat1[4];
<a name="line689"></a>  resultMat[5] = mat0[5] - mat1[5];
<a name="line690"></a>  resultMat[6] = mat0[6] - mat1[6];
<a name="line691"></a>  resultMat[7] = mat0[7] - mat1[7];
<a name="line692"></a>  resultMat[8] = mat0[8] - mat1[8];
<a name="line693"></a>  return resultMat;
<a name="line694"></a>};
<a name="line695"></a>
<a name="line696"></a>
<a name="line697"></a>/**
<a name="line698"></a> * Multiplies matrix mat0 with the given scalar, storing the result
<a name="line699"></a> * into resultMat.
<a name="line700"></a> *
<a name="line701"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line702"></a> * @param {number} scalar The scalar value to multiple to each element of mat.
<a name="line703"></a> * @param {goog.vec.Mat3.AnyType} resultMat The matrix to receive
<a name="line704"></a> *     the results (may be mat).
<a name="line705"></a> * @return {goog.vec.Mat3.AnyType} return resultMat so that operations can be
<a name="line706"></a> *     chained together.
<a name="line707"></a> */
<a name="line708"></a>goog.vec.Mat3.multScalar = function(mat, scalar, resultMat) {
<a name="line709"></a>  resultMat[0] = mat[0] * scalar;
<a name="line710"></a>  resultMat[1] = mat[1] * scalar;
<a name="line711"></a>  resultMat[2] = mat[2] * scalar;
<a name="line712"></a>  resultMat[3] = mat[3] * scalar;
<a name="line713"></a>  resultMat[4] = mat[4] * scalar;
<a name="line714"></a>  resultMat[5] = mat[5] * scalar;
<a name="line715"></a>  resultMat[6] = mat[6] * scalar;
<a name="line716"></a>  resultMat[7] = mat[7] * scalar;
<a name="line717"></a>  resultMat[8] = mat[8] * scalar;
<a name="line718"></a>  return resultMat;
<a name="line719"></a>};
<a name="line720"></a>
<a name="line721"></a>
<a name="line722"></a>/**
<a name="line723"></a> * Multiplies the two matrices mat0 and mat1 using matrix multiplication,
<a name="line724"></a> * storing the result into resultMat.
<a name="line725"></a> *
<a name="line726"></a> * @param {goog.vec.Mat3.AnyType} mat0 The first (left hand) matrix.
<a name="line727"></a> * @param {goog.vec.Mat3.AnyType} mat1 The second (right hand) matrix.
<a name="line728"></a> * @param {goog.vec.Mat3.AnyType} resultMat The matrix to receive
<a name="line729"></a> *     the results (may be either mat0 or mat1).
<a name="line730"></a> * @return {goog.vec.Mat3.AnyType} return resultMat so that operations can be
<a name="line731"></a> *     chained together.
<a name="line732"></a> */
<a name="line733"></a>goog.vec.Mat3.multMat = function(mat0, mat1, resultMat) {
<a name="line734"></a>  var a00 = mat0[0], a10 = mat0[1], a20 = mat0[2];
<a name="line735"></a>  var a01 = mat0[3], a11 = mat0[4], a21 = mat0[5];
<a name="line736"></a>  var a02 = mat0[6], a12 = mat0[7], a22 = mat0[8];
<a name="line737"></a>
<a name="line738"></a>  var b00 = mat1[0], b10 = mat1[1], b20 = mat1[2];
<a name="line739"></a>  var b01 = mat1[3], b11 = mat1[4], b21 = mat1[5];
<a name="line740"></a>  var b02 = mat1[6], b12 = mat1[7], b22 = mat1[8];
<a name="line741"></a>
<a name="line742"></a>  resultMat[0] = a00 * b00 + a01 * b10 + a02 * b20;
<a name="line743"></a>  resultMat[1] = a10 * b00 + a11 * b10 + a12 * b20;
<a name="line744"></a>  resultMat[2] = a20 * b00 + a21 * b10 + a22 * b20;
<a name="line745"></a>  resultMat[3] = a00 * b01 + a01 * b11 + a02 * b21;
<a name="line746"></a>  resultMat[4] = a10 * b01 + a11 * b11 + a12 * b21;
<a name="line747"></a>  resultMat[5] = a20 * b01 + a21 * b11 + a22 * b21;
<a name="line748"></a>  resultMat[6] = a00 * b02 + a01 * b12 + a02 * b22;
<a name="line749"></a>  resultMat[7] = a10 * b02 + a11 * b12 + a12 * b22;
<a name="line750"></a>  resultMat[8] = a20 * b02 + a21 * b12 + a22 * b22;
<a name="line751"></a>  return resultMat;
<a name="line752"></a>};
<a name="line753"></a>
<a name="line754"></a>
<a name="line755"></a>/**
<a name="line756"></a> * Transposes the given matrix mat storing the result into resultMat.
<a name="line757"></a> *
<a name="line758"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix to transpose.
<a name="line759"></a> * @param {goog.vec.Mat3.AnyType} resultMat The matrix to receive
<a name="line760"></a> *     the results (may be mat).
<a name="line761"></a> * @return {goog.vec.Mat3.AnyType} return resultMat so that operations can be
<a name="line762"></a> *     chained together.
<a name="line763"></a> */
<a name="line764"></a>goog.vec.Mat3.transpose = function(mat, resultMat) {
<a name="line765"></a>  if (resultMat == mat) {
<a name="line766"></a>    var a10 = mat[1], a20 = mat[2], a21 = mat[5];
<a name="line767"></a>    resultMat[1] = mat[3];
<a name="line768"></a>    resultMat[2] = mat[6];
<a name="line769"></a>    resultMat[3] = a10;
<a name="line770"></a>    resultMat[5] = mat[7];
<a name="line771"></a>    resultMat[6] = a20;
<a name="line772"></a>    resultMat[7] = a21;
<a name="line773"></a>  } else {
<a name="line774"></a>    resultMat[0] = mat[0];
<a name="line775"></a>    resultMat[1] = mat[3];
<a name="line776"></a>    resultMat[2] = mat[6];
<a name="line777"></a>    resultMat[3] = mat[1];
<a name="line778"></a>    resultMat[4] = mat[4];
<a name="line779"></a>    resultMat[5] = mat[7];
<a name="line780"></a>    resultMat[6] = mat[2];
<a name="line781"></a>    resultMat[7] = mat[5];
<a name="line782"></a>    resultMat[8] = mat[8];
<a name="line783"></a>  }
<a name="line784"></a>  return resultMat;
<a name="line785"></a>};
<a name="line786"></a>
<a name="line787"></a>
<a name="line788"></a>/**
<a name="line789"></a> * Computes the inverse of mat0 storing the result into resultMat. If the
<a name="line790"></a> * inverse is defined, this function returns true, false otherwise.
<a name="line791"></a> *
<a name="line792"></a> * @param {goog.vec.Mat3.AnyType} mat0 The matrix to invert.
<a name="line793"></a> * @param {goog.vec.Mat3.AnyType} resultMat The matrix to receive
<a name="line794"></a> *     the result (may be mat0).
<a name="line795"></a> * @return {boolean} True if the inverse is defined. If false is returned,
<a name="line796"></a> *     resultMat is not modified.
<a name="line797"></a> */
<a name="line798"></a>goog.vec.Mat3.invert = function(mat0, resultMat) {
<a name="line799"></a>  var a00 = mat0[0], a10 = mat0[1], a20 = mat0[2];
<a name="line800"></a>  var a01 = mat0[3], a11 = mat0[4], a21 = mat0[5];
<a name="line801"></a>  var a02 = mat0[6], a12 = mat0[7], a22 = mat0[8];
<a name="line802"></a>
<a name="line803"></a>  var t00 = a11 * a22 - a12 * a21;
<a name="line804"></a>  var t10 = a12 * a20 - a10 * a22;
<a name="line805"></a>  var t20 = a10 * a21 - a11 * a20;
<a name="line806"></a>  var det = a00 * t00 + a01 * t10 + a02 * t20;
<a name="line807"></a>  if (det == 0) {
<a name="line808"></a>    return false;
<a name="line809"></a>  }
<a name="line810"></a>
<a name="line811"></a>  var idet = 1 / det;
<a name="line812"></a>  resultMat[0] = t00 * idet;
<a name="line813"></a>  resultMat[3] = (a02 * a21 - a01 * a22) * idet;
<a name="line814"></a>  resultMat[6] = (a01 * a12 - a02 * a11) * idet;
<a name="line815"></a>
<a name="line816"></a>  resultMat[1] = t10 * idet;
<a name="line817"></a>  resultMat[4] = (a00 * a22 - a02 * a20) * idet;
<a name="line818"></a>  resultMat[7] = (a02 * a10 - a00 * a12) * idet;
<a name="line819"></a>
<a name="line820"></a>  resultMat[2] = t20 * idet;
<a name="line821"></a>  resultMat[5] = (a01 * a20 - a00 * a21) * idet;
<a name="line822"></a>  resultMat[8] = (a00 * a11 - a01 * a10) * idet;
<a name="line823"></a>  return true;
<a name="line824"></a>};
<a name="line825"></a>
<a name="line826"></a>
<a name="line827"></a>/**
<a name="line828"></a> * Returns true if the components of mat0 are equal to the components of mat1.
<a name="line829"></a> *
<a name="line830"></a> * @param {goog.vec.Mat3.AnyType} mat0 The first matrix.
<a name="line831"></a> * @param {goog.vec.Mat3.AnyType} mat1 The second matrix.
<a name="line832"></a> * @return {boolean} True if the the two matrices are equivalent.
<a name="line833"></a> */
<a name="line834"></a>goog.vec.Mat3.equals = function(mat0, mat1) {
<a name="line835"></a>  return mat0.length == mat1.length &amp;&amp;
<a name="line836"></a>      mat0[0] == mat1[0] &amp;&amp; mat0[1] == mat1[1] &amp;&amp; mat0[2] == mat1[2] &amp;&amp;
<a name="line837"></a>      mat0[3] == mat1[3] &amp;&amp; mat0[4] == mat1[4] &amp;&amp; mat0[5] == mat1[5] &amp;&amp;
<a name="line838"></a>      mat0[6] == mat1[6] &amp;&amp; mat0[7] == mat1[7] &amp;&amp; mat0[8] == mat1[8];
<a name="line839"></a>};
<a name="line840"></a>
<a name="line841"></a>
<a name="line842"></a>/**
<a name="line843"></a> * Transforms the given vector with the given matrix storing the resulting,
<a name="line844"></a> * transformed matrix into resultVec.
<a name="line845"></a> *
<a name="line846"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix supplying the transformation.
<a name="line847"></a> * @param {goog.vec.Vec3.AnyType} vec The vector to transform.
<a name="line848"></a> * @param {goog.vec.Vec3.AnyType} resultVec The vector to
<a name="line849"></a> *     receive the results (may be vec).
<a name="line850"></a> * @return {goog.vec.Vec3.AnyType} return resultVec so that operations can be
<a name="line851"></a> *     chained together.
<a name="line852"></a> */
<a name="line853"></a>goog.vec.Mat3.multVec3 = function(mat, vec, resultVec) {
<a name="line854"></a>  var x = vec[0], y = vec[1], z = vec[2];
<a name="line855"></a>  resultVec[0] = x * mat[0] + y * mat[3] + z * mat[6];
<a name="line856"></a>  resultVec[1] = x * mat[1] + y * mat[4] + z * mat[7];
<a name="line857"></a>  resultVec[2] = x * mat[2] + y * mat[5] + z * mat[8];
<a name="line858"></a>  return resultVec;
<a name="line859"></a>};
<a name="line860"></a>
<a name="line861"></a>
<a name="line862"></a>/**
<a name="line863"></a> * Makes the given 3x3 matrix a translation matrix with x and y
<a name="line864"></a> * translation values.
<a name="line865"></a> *
<a name="line866"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line867"></a> * @param {number} x The translation along the x axis.
<a name="line868"></a> * @param {number} y The translation along the y axis.
<a name="line869"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line870"></a> *     chained.
<a name="line871"></a> */
<a name="line872"></a>goog.vec.Mat3.makeTranslate = function(mat, x, y) {
<a name="line873"></a>  goog.vec.Mat3.makeIdentity(mat);
<a name="line874"></a>  return goog.vec.Mat3.setColumnValues(mat, 2, x, y, 1);
<a name="line875"></a>};
<a name="line876"></a>
<a name="line877"></a>
<a name="line878"></a>/**
<a name="line879"></a> * Makes the given 3x3 matrix a scale matrix with x, y, and z scale factors.
<a name="line880"></a> *
<a name="line881"></a> * @param {goog.vec.Mat3.AnyType} mat The 3x3 (9-element) matrix
<a name="line882"></a> *     array to receive the new scale matrix.
<a name="line883"></a> * @param {number} x The scale along the x axis.
<a name="line884"></a> * @param {number} y The scale along the y axis.
<a name="line885"></a> * @param {number} z The scale along the z axis.
<a name="line886"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line887"></a> *     chained.
<a name="line888"></a> */
<a name="line889"></a>goog.vec.Mat3.makeScale = function(mat, x, y, z) {
<a name="line890"></a>  goog.vec.Mat3.makeIdentity(mat);
<a name="line891"></a>  return goog.vec.Mat3.setDiagonalValues(mat, x, y, z);
<a name="line892"></a>};
<a name="line893"></a>
<a name="line894"></a>
<a name="line895"></a>/**
<a name="line896"></a> * Makes the given 3x3 matrix a rotation matrix with the given rotation
<a name="line897"></a> * angle about the axis defined by the vector (ax, ay, az).
<a name="line898"></a> *
<a name="line899"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line900"></a> * @param {number} angle The rotation angle in radians.
<a name="line901"></a> * @param {number} ax The x component of the rotation axis.
<a name="line902"></a> * @param {number} ay The y component of the rotation axis.
<a name="line903"></a> * @param {number} az The z component of the rotation axis.
<a name="line904"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line905"></a> *     chained.
<a name="line906"></a> */
<a name="line907"></a>goog.vec.Mat3.makeRotate = function(mat, angle, ax, ay, az) {
<a name="line908"></a>  var c = Math.cos(angle);
<a name="line909"></a>  var d = 1 - c;
<a name="line910"></a>  var s = Math.sin(angle);
<a name="line911"></a>
<a name="line912"></a>  return goog.vec.Mat3.setFromValues(mat,
<a name="line913"></a>      ax * ax * d + c,
<a name="line914"></a>      ax * ay * d + az * s,
<a name="line915"></a>      ax * az * d - ay * s,
<a name="line916"></a>
<a name="line917"></a>      ax * ay * d - az * s,
<a name="line918"></a>      ay * ay * d + c,
<a name="line919"></a>      ay * az * d + ax * s,
<a name="line920"></a>
<a name="line921"></a>      ax * az * d + ay * s,
<a name="line922"></a>      ay * az * d - ax * s,
<a name="line923"></a>      az * az * d + c);
<a name="line924"></a>};
<a name="line925"></a>
<a name="line926"></a>
<a name="line927"></a>/**
<a name="line928"></a> * Makes the given 3x3 matrix a rotation matrix with the given rotation
<a name="line929"></a> * angle about the X axis.
<a name="line930"></a> *
<a name="line931"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line932"></a> * @param {number} angle The rotation angle in radians.
<a name="line933"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line934"></a> *     chained.
<a name="line935"></a> */
<a name="line936"></a>goog.vec.Mat3.makeRotateX = function(mat, angle) {
<a name="line937"></a>  var c = Math.cos(angle);
<a name="line938"></a>  var s = Math.sin(angle);
<a name="line939"></a>  return goog.vec.Mat3.setFromValues(mat,
<a name="line940"></a>                                     1, 0, 0,
<a name="line941"></a>                                     0, c, s,
<a name="line942"></a>                                     0, -s, c);
<a name="line943"></a>};
<a name="line944"></a>
<a name="line945"></a>
<a name="line946"></a>/**
<a name="line947"></a> * Makes the given 3x3 matrix a rotation matrix with the given rotation
<a name="line948"></a> * angle about the Y axis.
<a name="line949"></a> *
<a name="line950"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line951"></a> * @param {number} angle The rotation angle in radians.
<a name="line952"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line953"></a> *     chained.
<a name="line954"></a> */
<a name="line955"></a>goog.vec.Mat3.makeRotateY = function(mat, angle) {
<a name="line956"></a>  var c = Math.cos(angle);
<a name="line957"></a>  var s = Math.sin(angle);
<a name="line958"></a>  return goog.vec.Mat3.setFromValues(mat,
<a name="line959"></a>                                     c, 0, -s,
<a name="line960"></a>                                     0, 1, 0,
<a name="line961"></a>                                     s, 0, c);
<a name="line962"></a>};
<a name="line963"></a>
<a name="line964"></a>
<a name="line965"></a>/**
<a name="line966"></a> * Makes the given 3x3 matrix a rotation matrix with the given rotation
<a name="line967"></a> * angle about the Z axis.
<a name="line968"></a> *
<a name="line969"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line970"></a> * @param {number} angle The rotation angle in radians.
<a name="line971"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line972"></a> *     chained.
<a name="line973"></a> */
<a name="line974"></a>goog.vec.Mat3.makeRotateZ = function(mat, angle) {
<a name="line975"></a>  var c = Math.cos(angle);
<a name="line976"></a>  var s = Math.sin(angle);
<a name="line977"></a>  return goog.vec.Mat3.setFromValues(mat,
<a name="line978"></a>                                     c, s, 0,
<a name="line979"></a>                                     -s, c, 0,
<a name="line980"></a>                                     0, 0, 1);
<a name="line981"></a>};
<a name="line982"></a>
<a name="line983"></a>
<a name="line984"></a>/**
<a name="line985"></a> * Rotate the given matrix by angle about the x,y,z axis.  Equivalent to:
<a name="line986"></a> * goog.vec.Mat3.multMat(
<a name="line987"></a> *     mat,
<a name="line988"></a> *     goog.vec.Mat3.makeRotate(goog.vec.Mat3.create(), angle, x, y, z),
<a name="line989"></a> *     mat);
<a name="line990"></a> *
<a name="line991"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line992"></a> * @param {number} angle The angle in radians.
<a name="line993"></a> * @param {number} x The x component of the rotation axis.
<a name="line994"></a> * @param {number} y The y component of the rotation axis.
<a name="line995"></a> * @param {number} z The z component of the rotation axis.
<a name="line996"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line997"></a> *     chained.
<a name="line998"></a> */
<a name="line999"></a>goog.vec.Mat3.rotate = function(mat, angle, x, y, z) {
<a name="line1000"></a>  var m00 = mat[0], m10 = mat[1], m20 = mat[2];
<a name="line1001"></a>  var m01 = mat[3], m11 = mat[4], m21 = mat[5];
<a name="line1002"></a>  var m02 = mat[6], m12 = mat[7], m22 = mat[8];
<a name="line1003"></a>
<a name="line1004"></a>  var cosAngle = Math.cos(angle);
<a name="line1005"></a>  var sinAngle = Math.sin(angle);
<a name="line1006"></a>  var diffCosAngle = 1 - cosAngle;
<a name="line1007"></a>  var r00 = x * x * diffCosAngle + cosAngle;
<a name="line1008"></a>  var r10 = x * y * diffCosAngle + z * sinAngle;
<a name="line1009"></a>  var r20 = x * z * diffCosAngle - y * sinAngle;
<a name="line1010"></a>
<a name="line1011"></a>  var r01 = x * y * diffCosAngle - z * sinAngle;
<a name="line1012"></a>  var r11 = y * y * diffCosAngle + cosAngle;
<a name="line1013"></a>  var r21 = y * z * diffCosAngle + x * sinAngle;
<a name="line1014"></a>
<a name="line1015"></a>  var r02 = x * z * diffCosAngle + y * sinAngle;
<a name="line1016"></a>  var r12 = y * z * diffCosAngle - x * sinAngle;
<a name="line1017"></a>  var r22 = z * z * diffCosAngle + cosAngle;
<a name="line1018"></a>
<a name="line1019"></a>  return goog.vec.Mat3.setFromValues(
<a name="line1020"></a>      mat,
<a name="line1021"></a>      m00 * r00 + m01 * r10 + m02 * r20,
<a name="line1022"></a>      m10 * r00 + m11 * r10 + m12 * r20,
<a name="line1023"></a>      m20 * r00 + m21 * r10 + m22 * r20,
<a name="line1024"></a>
<a name="line1025"></a>      m00 * r01 + m01 * r11 + m02 * r21,
<a name="line1026"></a>      m10 * r01 + m11 * r11 + m12 * r21,
<a name="line1027"></a>      m20 * r01 + m21 * r11 + m22 * r21,
<a name="line1028"></a>
<a name="line1029"></a>      m00 * r02 + m01 * r12 + m02 * r22,
<a name="line1030"></a>      m10 * r02 + m11 * r12 + m12 * r22,
<a name="line1031"></a>      m20 * r02 + m21 * r12 + m22 * r22);
<a name="line1032"></a>};
<a name="line1033"></a>
<a name="line1034"></a>
<a name="line1035"></a>/**
<a name="line1036"></a> * Rotate the given matrix by angle about the x axis.  Equivalent to:
<a name="line1037"></a> * goog.vec.Mat3.multMat(
<a name="line1038"></a> *     mat,
<a name="line1039"></a> *     goog.vec.Mat3.makeRotateX(goog.vec.Mat3.create(), angle),
<a name="line1040"></a> *     mat);
<a name="line1041"></a> *
<a name="line1042"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line1043"></a> * @param {number} angle The angle in radians.
<a name="line1044"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line1045"></a> *     chained.
<a name="line1046"></a> */
<a name="line1047"></a>goog.vec.Mat3.rotateX = function(mat, angle) {
<a name="line1048"></a>  var m01 = mat[3], m11 = mat[4], m21 = mat[5];
<a name="line1049"></a>  var m02 = mat[6], m12 = mat[7], m22 = mat[8];
<a name="line1050"></a>
<a name="line1051"></a>  var c = Math.cos(angle);
<a name="line1052"></a>  var s = Math.sin(angle);
<a name="line1053"></a>
<a name="line1054"></a>  mat[3] = m01 * c + m02 * s;
<a name="line1055"></a>  mat[4] = m11 * c + m12 * s;
<a name="line1056"></a>  mat[5] = m21 * c + m22 * s;
<a name="line1057"></a>  mat[6] = m01 * -s + m02 * c;
<a name="line1058"></a>  mat[7] = m11 * -s + m12 * c;
<a name="line1059"></a>  mat[8] = m21 * -s + m22 * c;
<a name="line1060"></a>
<a name="line1061"></a>  return mat;
<a name="line1062"></a>};
<a name="line1063"></a>
<a name="line1064"></a>
<a name="line1065"></a>/**
<a name="line1066"></a> * Rotate the given matrix by angle about the y axis.  Equivalent to:
<a name="line1067"></a> * goog.vec.Mat3.multMat(
<a name="line1068"></a> *     mat,
<a name="line1069"></a> *     goog.vec.Mat3.makeRotateY(goog.vec.Mat3.create(), angle),
<a name="line1070"></a> *     mat);
<a name="line1071"></a> *
<a name="line1072"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line1073"></a> * @param {number} angle The angle in radians.
<a name="line1074"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line1075"></a> *     chained.
<a name="line1076"></a> */
<a name="line1077"></a>goog.vec.Mat3.rotateY = function(mat, angle) {
<a name="line1078"></a>  var m00 = mat[0], m10 = mat[1], m20 = mat[2];
<a name="line1079"></a>  var m02 = mat[6], m12 = mat[7], m22 = mat[8];
<a name="line1080"></a>
<a name="line1081"></a>  var c = Math.cos(angle);
<a name="line1082"></a>  var s = Math.sin(angle);
<a name="line1083"></a>
<a name="line1084"></a>  mat[0] = m00 * c + m02 * -s;
<a name="line1085"></a>  mat[1] = m10 * c + m12 * -s;
<a name="line1086"></a>  mat[2] = m20 * c + m22 * -s;
<a name="line1087"></a>  mat[6] = m00 * s + m02 * c;
<a name="line1088"></a>  mat[7] = m10 * s + m12 * c;
<a name="line1089"></a>  mat[8] = m20 * s + m22 * c;
<a name="line1090"></a>
<a name="line1091"></a>  return mat;
<a name="line1092"></a>};
<a name="line1093"></a>
<a name="line1094"></a>
<a name="line1095"></a>/**
<a name="line1096"></a> * Rotate the given matrix by angle about the z axis.  Equivalent to:
<a name="line1097"></a> * goog.vec.Mat3.multMat(
<a name="line1098"></a> *     mat,
<a name="line1099"></a> *     goog.vec.Mat3.makeRotateZ(goog.vec.Mat3.create(), angle),
<a name="line1100"></a> *     mat);
<a name="line1101"></a> *
<a name="line1102"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line1103"></a> * @param {number} angle The angle in radians.
<a name="line1104"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line1105"></a> *     chained.
<a name="line1106"></a> */
<a name="line1107"></a>goog.vec.Mat3.rotateZ = function(mat, angle) {
<a name="line1108"></a>  var m00 = mat[0], m10 = mat[1], m20 = mat[2];
<a name="line1109"></a>  var m01 = mat[3], m11 = mat[4], m21 = mat[5];
<a name="line1110"></a>
<a name="line1111"></a>  var c = Math.cos(angle);
<a name="line1112"></a>  var s = Math.sin(angle);
<a name="line1113"></a>
<a name="line1114"></a>  mat[0] = m00 * c + m01 * s;
<a name="line1115"></a>  mat[1] = m10 * c + m11 * s;
<a name="line1116"></a>  mat[2] = m20 * c + m21 * s;
<a name="line1117"></a>  mat[3] = m00 * -s + m01 * c;
<a name="line1118"></a>  mat[4] = m10 * -s + m11 * c;
<a name="line1119"></a>  mat[5] = m20 * -s + m21 * c;
<a name="line1120"></a>
<a name="line1121"></a>  return mat;
<a name="line1122"></a>};
<a name="line1123"></a>
<a name="line1124"></a>
<a name="line1125"></a>/**
<a name="line1126"></a> * Makes the given 3x3 matrix a rotation matrix given Euler angles using
<a name="line1127"></a> * the ZXZ convention.
<a name="line1128"></a> * Given the euler angles [theta1, theta2, theta3], the rotation is defined as
<a name="line1129"></a> * rotation = rotation_z(theta1) * rotation_x(theta2) * rotation_z(theta3),
<a name="line1130"></a> * with theta1 in [0, 2 * pi], theta2 in [0, pi] and theta3 in [0, 2 * pi].
<a name="line1131"></a> * rotation_x(theta) means rotation around the X axis of theta radians.
<a name="line1132"></a> *
<a name="line1133"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line1134"></a> * @param {number} theta1 The angle of rotation around the Z axis in radians.
<a name="line1135"></a> * @param {number} theta2 The angle of rotation around the X axis in radians.
<a name="line1136"></a> * @param {number} theta3 The angle of rotation around the Z axis in radians.
<a name="line1137"></a> * @return {goog.vec.Mat3.AnyType} return mat so that operations can be
<a name="line1138"></a> *     chained.
<a name="line1139"></a> */
<a name="line1140"></a>goog.vec.Mat3.makeEulerZXZ = function(mat, theta1, theta2, theta3) {
<a name="line1141"></a>  var c1 = Math.cos(theta1);
<a name="line1142"></a>  var s1 = Math.sin(theta1);
<a name="line1143"></a>
<a name="line1144"></a>  var c2 = Math.cos(theta2);
<a name="line1145"></a>  var s2 = Math.sin(theta2);
<a name="line1146"></a>
<a name="line1147"></a>  var c3 = Math.cos(theta3);
<a name="line1148"></a>  var s3 = Math.sin(theta3);
<a name="line1149"></a>
<a name="line1150"></a>  mat[0] = c1 * c3 - c2 * s1 * s3;
<a name="line1151"></a>  mat[1] = c2 * c1 * s3 + c3 * s1;
<a name="line1152"></a>  mat[2] = s3 * s2;
<a name="line1153"></a>
<a name="line1154"></a>  mat[3] = -c1 * s3 - c3 * c2 * s1;
<a name="line1155"></a>  mat[4] = c1 * c2 * c3 - s1 * s3;
<a name="line1156"></a>  mat[5] = c3 * s2;
<a name="line1157"></a>
<a name="line1158"></a>  mat[6] = s2 * s1;
<a name="line1159"></a>  mat[7] = -c1 * s2;
<a name="line1160"></a>  mat[8] = c2;
<a name="line1161"></a>
<a name="line1162"></a>  return mat;
<a name="line1163"></a>};
<a name="line1164"></a>
<a name="line1165"></a>
<a name="line1166"></a>/**
<a name="line1167"></a> * Decomposes a rotation matrix into Euler angles using the ZXZ convention so
<a name="line1168"></a> * that rotation = rotation_z(theta1) * rotation_x(theta2) * rotation_z(theta3),
<a name="line1169"></a> * with theta1 in [0, 2 * pi], theta2 in [0, pi] and theta3 in [0, 2 * pi].
<a name="line1170"></a> * rotation_x(theta) means rotation around the X axis of theta radians.
<a name="line1171"></a> *
<a name="line1172"></a> * @param {goog.vec.Mat3.AnyType} mat The matrix.
<a name="line1173"></a> * @param {goog.vec.Vec3.AnyType} euler The ZXZ Euler angles in
<a name="line1174"></a> *     radians as [theta1, theta2, theta3].
<a name="line1175"></a> * @param {boolean=} opt_theta2IsNegative Whether theta2 is in [-pi, 0] instead
<a name="line1176"></a> *     of the default [0, pi].
<a name="line1177"></a> * @return {goog.vec.Vec3.AnyType} return euler so that operations can be
<a name="line1178"></a> *     chained together.
<a name="line1179"></a> */
<a name="line1180"></a>goog.vec.Mat3.toEulerZXZ = function(mat, euler, opt_theta2IsNegative) {
<a name="line1181"></a>  // There is an ambiguity in the sign of sinTheta2 because of the sqrt.
<a name="line1182"></a>  var sinTheta2 = Math.sqrt(mat[2] * mat[2] + mat[5] * mat[5]);
<a name="line1183"></a>
<a name="line1184"></a>  // By default we explicitely constrain theta2 to be in [0, pi],
<a name="line1185"></a>  // so sinTheta2 is always positive. We can change the behavior and specify
<a name="line1186"></a>  // theta2 to be negative in [-pi, 0] with opt_Theta2IsNegative.
<a name="line1187"></a>  var signTheta2 = opt_theta2IsNegative ? -1 : 1;
<a name="line1188"></a>
<a name="line1189"></a>  if (sinTheta2 &gt; goog.vec.EPSILON) {
<a name="line1190"></a>    euler[2] = Math.atan2(mat[2] * signTheta2, mat[5] * signTheta2);
<a name="line1191"></a>    euler[1] = Math.atan2(sinTheta2 * signTheta2, mat[8]);
<a name="line1192"></a>    euler[0] = Math.atan2(mat[6] * signTheta2, -mat[7] * signTheta2);
<a name="line1193"></a>  } else {
<a name="line1194"></a>    // There is also an arbitrary choice for theta1 = 0 or theta2 = 0 here.
<a name="line1195"></a>    // We assume theta1 = 0 as some applications do not allow the camera to roll
<a name="line1196"></a>    // (i.e. have theta1 != 0).
<a name="line1197"></a>    euler[0] = 0;
<a name="line1198"></a>    euler[1] = Math.atan2(sinTheta2 * signTheta2, mat[8]);
<a name="line1199"></a>    euler[2] = Math.atan2(mat[1], mat[0]);
<a name="line1200"></a>  }
<a name="line1201"></a>
<a name="line1202"></a>  // Atan2 outputs angles in [-pi, pi] so we bring them back to [0, 2 * pi].
<a name="line1203"></a>  euler[0] = (euler[0] + Math.PI * 2) % (Math.PI * 2);
<a name="line1204"></a>  euler[2] = (euler[2] + Math.PI * 2) % (Math.PI * 2);
<a name="line1205"></a>  // For theta2 we want the angle to be in [0, pi] or [-pi, 0] depending on
<a name="line1206"></a>  // signTheta2.
<a name="line1207"></a>  euler[1] = ((euler[1] * signTheta2 + Math.PI * 2) % (Math.PI * 2)) *
<a name="line1208"></a>      signTheta2;
<a name="line1209"></a>
<a name="line1210"></a>  return euler;
<a name="line1211"></a>};
</pre>


</body>
</html>
